package demo.um.jsf.converter;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;

@FacesConverter("demo.um.SexConverter")
public class SexConverter implements Converter {

	@Override
	public Object getAsObject(FacesContext context, UIComponent component, String value) {
		return Boolean.valueOf("Male".equals(value) ? true : false);
	}

	@Override
	public String getAsString(FacesContext context, UIComponent component, Object value) {
		return Boolean.valueOf(value.toString()) ? "Male" : "Female";
	}

}
